package main

import (
	"fmt"
)

func main() {
	loopRange()
}

func loop1()  {
	sum := 0
	for i:=0; i<=10; i++{
		sum += i
	}

	fmt.Println("sum==", sum)
}

func loop2()  {
	// 判断sum<=10 
	// sum = 1+10 为true
	// post为null,直接跳出循环
	sum := 1
	for ; sum <= 10; {
					sum += sum
	}
	fmt.Println(sum)
}

func loop3()  {
	sum := 1
	for sum <= 10{
					sum += sum
	}
	fmt.Println(sum)
}

func loop4()  {
	sum:=10
	for{
		sum++
		fmt.Println("sum-for", sum)
	}
	fmt.Println("sum=", sum)
}

func loopRange()  {
	nameList := []string {"google", "facebook"}

	for key, value:= range nameList{
		fmt.Println("key=",key);
		fmt.Println("value=", value);
	}

	numberList := [6]int{1,2,3,4,5}
	for key, value:=range numberList{
		fmt.Println(key, value)
	}
}